/*
 * Poyke Framework
 * Copyright (C) 2010 Poyke <http://code.google.com/p/poyke/>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include "StdAfx.h"

int main(int argc, char **argv)
{
	switch(sCoreLoader->LoadCore(false))
	{
	case LOAD_CORE_SUCCESS:
		Logging::Debug("PoykeMain", "Core loaded");
		break;
	case LOAD_CORE_FAIL_NO_DLL:
		Logging::Error("PoykeMain", "Unable to find core DLL");
		exit(1);
	case LOAD_CORE_FAIL_NO_ENTRY:
		Logging::Error("PoykeMain", "Unable to find entry point");
		exit(2);
	case LOAD_CORE_FAIL_NO_SAVESTATE:
		Logging::Error("PoykeMain", "Unable to find save state function");
		exit(3);
	}
	switch(sCoreLoader->UnloadCore(false))
	{
	case UNLOAD_CORE_FAIL_IN_USE:
		Logging::Error("PoykeMain", "Unable to unload DLL which is in use");
		exit(4);
	case UNLOAD_CORE_FAIL_UNKNOWN:
		Logging::Error("PoykeMain", "Unable to unload DLL");
		exit(5);
	case UNLOAD_CORE_SUCCESS:
		Logging::Debug("PoykeMain", "Core unloaded");
	}
	Logging::Debug("PoykeMain", "Switch core.dll now");
	switch(sCoreLoader->LoadCore(false))
	{
	case LOAD_CORE_SUCCESS:
		Logging::Debug("PoykeMain", "Core loaded");
		break;
	case LOAD_CORE_FAIL_NO_DLL:
		Logging::Error("PoykeMain", "Unable to find core DLL");
		exit(1);
	case LOAD_CORE_FAIL_NO_ENTRY:
		Logging::Error("PoykeMain", "Unable to find entry point");
		exit(2);
	case LOAD_CORE_FAIL_NO_SAVESTATE:
		Logging::Error("PoykeMain", "Unable to find save state function");
		exit(3);
	}
	exit(0);
}
